package com.zzj.ServiceImpl;

import com.zzj.dao.DeptDao;
import com.zzj.dao.UserDao;
import com.zzj.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao dao;
    @Autowired
    private UserDao userDao;

    /**
     * 查询出所有部门的名称
     * @return 返回string集合
     */
    @Override
    public List<String> findAllDname() {
        List<String> list = dao.findAllDname();
        return list;
    }

    /**
     * 根据前端传过来的用户Id,和此用户所选的部门名称，进行判断，
     * 当前的用户能不能，填写这个部门
     * @param id
     * @param dname
     * @return
     */
    @Override
    public boolean assertDname(int id, String dname) {
        List<String> role = userDao.findAllDname(id);
        System.out.println(role);
        System.out.println(role.contains(dname)+"===============");
        if (role.contains(dname)){
            return true;
        }
        return false;
    }

}
